{ "cells": [ { "cell_type": "markdown", "id": "c5793b89", "metadata": {}, "source": [ "# Create a Genome Topology for your Agent" ] }, { "cell_type": "markdown", "id": "ee8c352b", "metadata": {}, "source": [ "In order to create a agent you first need to create its genome. An agent's genome is very much like a genome in biology where it is an organism's complete set of genetic instructions. In this case, the genome is for an AI agent. A genome can be created manually, algorithmically, or using the Intelligent Artifacts Lab GUI (Lab). For now let's a genome that is located in the config folder named, 'demo-all.' All you need to do is upload the Genome in the Lab's Topology Creator. Moreover, a genome can be downloaded and uploaded for later use or sharing after spawning an agent (covered in the next section below). The genome file is a JavaScript Object Notation (JSON) string that can be imported as below:" ] }, { "cell_type": "code", "execution_count": 10, "id": "f852fe71", "metadata": { "scrolled": false }, "outputs": [], "source": [ "from ia.gaius.genome_info import Genome\n", "import json\n", "\n", "genome_topology = '''{\"elements\":{\"nodes\":[{\"data\":{\"name\":\"P1\",\"id\":\"p7ae0a0612\",\"type\":\"primitive\",\"sources\":[\"observables\"],\"manipulatives\":[],\"always_update_frequencies\":false,\"auto_act_method\":\"none\",\"auto_act_threshold\":0.8,\"auto_learn_method\":\"none\",\"classifier\":\"CVC\",\"datastore\":\"mongodb\",\"dynamic_sequence_length\":true,\"max_sequence_length\":0,\"sort\":true,\"process_predictions\":true,\"quiescence\":3,\"search_depth\":10,\"recall_threshold\":0.1,\"smoothness\":3,\"max_predictions\":100,\"persistence\":5},\"position\":{\"x\":587,\"y\":272.5975},\"group\":\"nodes\",\"removed\":false,\"selected\":false,\"selectable\":false,\"locked\":false,\"grabbable\":true,\"pannable\":false,\"classes\":\"\"},{\"data\":{\"name\":\"P2\",\"id\":\"p5b55a8399\",\"type\":\"primitive\",\"sources\":[\"m44ee0fd21\"],\"manipulatives\":[\"m44ee0fd21\"],\"always_update_frequencies\":false,\"auto_act_method\":\"none\",\"auto_act_threshold\":0.8,\"auto_learn_method\":\"none\",\"classifier\":\"CVC\",\"datastore\":\"mongodb\",\"dynamic_sequence_length\":true,\"max_sequence_length\":0,\"sort\":true,\"process_predictions\":true,\"quiescence\":3,\"search_depth\":10,\"recall_threshold\":0.1,\"smoothness\":3,\"max_predictions\":100,\"persistence\":5},\"position\":{\"x\":687,\"y\":272.5975},\"group\":\"nodes\",\"removed\":false,\"selected\":false,\"selectable\":false,\"locked\":false,\"grabbable\":true,\"pannable\":false,\"classes\":\"\"},{\"data\":{\"name\":\"P3\",\"id\":\"p85643c122\",\"type\":\"primitive\",\"sources\":[\"observables\"],\"manipulatives\":[\"mb94faab95\"],\"always_update_frequencies\":false,\"auto_act_method\":\"none\",\"auto_act_threshold\":0.8,\"auto_learn_method\":\"none\",\"classifier\":\"CVC\",\"datastore\":\"mongodb\",\"dynamic_sequence_length\":true,\"max_sequence_length\":0,\"sort\":true,\"process_predictions\":true,\"quiescence\":3,\"search_depth\":10,\"recall_threshold\":0.1,\"smoothness\":3,\"max_predictions\":100,\"persistence\":5},\"position\":{\"x\":789,\"y\":271.5975},\"group\":\"nodes\",\"removed\":false,\"selected\":false,\"selectable\":false,\"locked\":false,\"grabbable\":true,\"pannable\":false,\"classes\":\"\"},{\"data\":{\"displayName\":\"Multiplier\",\"mtype\":\"normal\",\"name\":\"emotiveMultiplier\",\"inputs\":[\"strings\",\"emotives\",\"vectors\"],\"outputs\":[\"strings\",\"emotives\",\"vectors\",\"predictions\"],\"description\":\"Multiplies emotive values by a configurable value.\",\"tags\":[\"emotives\",\"multiply\",\"multiplication\",\"multi\",\"value\",\"factor\"],\"category\":\"emotives\",\"genes\":{\"sources\":{\"alleles\":[],\"mutability\":0,\"value\":[\"observables\"],\"volatility\":0},\"multiplier\":{\"alleles\":[1,2,3,4,5,6,7,8,9,10],\"mutability\":0,\"value\":5,\"volatility\":0}},\"id\":\"m44ee0fd21\",\"type\":\"manipulative\",\"primitive\":\"p5b55a8399\"},\"position\":{\"x\":687,\"y\":372.5975},\"group\":\"nodes\",\"removed\":false,\"selected\":false,\"selectable\":false,\"locked\":false,\"grabbable\":true,\"pannable\":false,\"classes\":\"\"},{\"data\":{\"displayName\":\"abstraction\",\"name\":\"abstraction\",\"category\":\"standard\",\"mtype\":\"output\",\"description\":\"Output manipulative to forward abstracted predictions to other Primitives. The chosen field of the predictions are forwarded as. The are also forwarded. No are forwarded.\",\"tags\":[\"abstraction\",\"name\",\"present\",\"past\",\"future\",\"missing\",\"matches\",\"extras\",\"output\",\"forward\",\"abstract\",\"emotives\",\"strings\",\"emotive\",\"classification\"],\"genes\":{\"sources\":{\"alleles\":[],\"mutability\":0,\"value\":[\"cognition-data\"],\"volatility\":0},\"primitives\":{\"alleles\":[],\"mutability\":0,\"value\":[\"pc4dff12d6\"],\"volatility\":0},\"field\":{\"alleles\":[\"name\",\"past\",\"present\",\"future\",\"missing\",\"extras\",\"matches\",\"classification\"],\"mutability\":0,\"value\":[\"name\"],\"volatility\":0}},\"id\":\"mb94faab95\",\"type\":\"manipulative\",\"primitive\":\"p85643c122\"},\"position\":{\"x\":789,\"y\":171.59750000000003},\"group\":\"nodes\",\"removed\":false,\"selected\":false,\"selectable\":false,\"locked\":false,\"grabbable\":true,\"pannable\":false,\"classes\":\"\"},{\"data\":{\"name\":\"P4\",\"id\":\"pc4dff12d6\",\"type\":\"primitive\",\"sources\":[\"observables\"],\"manipulatives\":[],\"always_update_frequencies\":false,\"auto_act_method\":\"none\",\"auto_act_threshold\":0.8,\"auto_learn_method\":\"none\",\"classifier\":\"CVC\",\"datastore\":\"mongodb\",\"dynamic_sequence_length\":true,\"max_sequence_length\":0,\"sort\":true,\"process_predictions\":true,\"quiescence\":3,\"search_depth\":10,\"recall_threshold\":0.1,\"smoothness\":3,\"max_predictions\":100,\"persistence\":5},\"position\":{\"x\":788,\"y\":81.59750000000003},\"group\":\"nodes\",\"removed\":false,\"selected\":false,\"selectable\":false,\"locked\":false,\"grabbable\":true,\"pannable\":false,\"classes\":\"\"}],\"edges\":[{\"data\":{\"id\":\"eb7965422f\",\"source\":\"m44ee0fd21\",\"target\":\"p5b55a8399\",\"type\":\"edge\"},\"position\":{\"x\":0,\"y\":0},\"group\":\"edges\",\"removed\":false,\"selected\":false,\"selectable\":false,\"locked\":false,\"grabbable\":true,\"pannable\":true,\"classes\":\"\"},{\"data\":{\"id\":\"ec26380337\",\"source\":\"p85643c122\",\"target\":\"mb94faab95\",\"type\":\"edge\"},\"position\":{\"x\":0,\"y\":0},\"group\":\"edges\",\"removed\":false,\"selected\":false,\"selectable\":false,\"locked\":false,\"grabbable\":true,\"pannable\":true,\"classes\":\"abstractionEdge\"},{\"data\":{\"id\":\"e5dd3a5044\",\"source\":\"mb94faab95\",\"target\":\"pc4dff12d6\",\"type\":\"edge\"},\"position\":{\"x\":0,\"y\":0},\"group\":\"edges\",\"removed\":false,\"selected\":false,\"selectable\":false,\"locked\":false,\"grabbable\":true,\"pannable\":true,\"classes\":\"abstractionEdge\"}]},\"style\":[{\"selector\":\"edge\",\"style\":{\"target-arrow-shape\":\"triangle\",\"curve-style\":\"straight\",\"control-point-distances\":10,\"control-point-weights\":0.1,\"width\":1,\"overlay-color\":\"#fff\"}},{\"selector\":\"edge.curved\",\"style\":{\"curve-style\":\"bezier\"}}],\"data\":{},\"zoomingEnabled\":true,\"userZoomingEnabled\":true,\"zoom\":1,\"minZoom\":1e-50,\"maxZoom\":1,\"panningEnabled\":true,\"userPanningEnabled\":true,\"pan\":{\"x\":0,\"y\":0},\"boxSelectionEnabled\":false,\"renderer\":{\"name\":\"canvas\"},\"wheelSensitivity\":0.1,\"motionBlur\":false,\"agent\":\"demo-all\",\"description\":\"tutorial\"}'''\n", "genome = Genome(json.loads(genome_topology))" ] }, { "cell_type": "markdown", "id": "482958df", "metadata": {}, "source": [ "Parameter values in genomes are intended to be modified. Since the genome file is a JSON object, modifying values is easy. You can also use the Genome object class to easily find nodes and values for modification.\n", "\n", "The following example will change the `'recall_threshold'` and `'max_predictions'` of the primitive 'P1':" ] }, { "cell_type": "code", "execution_count": 20, "id": "f5090ba4", "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "P4: \n", " ID : pc4dff12d6 \n", " Recall Threshold : 0.1 \n", " Max Predictions : 100\n" ] } ], "source": [ "for p in genome.primitives.values():\n", " if p['name'] == 'P1':\n", " p['recall_threshold'] = 0.1\n", " p['max_predictions'] = 10\n", " \n", "print(\"%s: \\\n", " \\n ID : %s \\\n", " \\n Recall Threshold : %s \\\n", " \\n Max Predictions : %s\" %(p['name'], p['id'], p['recall_threshold'], p['max_predictions']))" ] }, { "cell_type": "code", "execution_count": null, "id": "61ec5b53", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.5" } }, "nbformat": 4, "nbformat_minor": 5 }